package com.leps.nq.common.vo;

import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;

import java.util.List;

@ApiModel
@Getter
@Setter
public class PageVo<T> {
    @ApiModelProperty("总行数")
    public long total;
    @ApiModelProperty("当前页数据")
    public List<T> list;

    public PageVo(long total, List<T> list) {
        this.total = total;
        this.list = list;
    }

    public static <T> PageVo<T> of(long total, List<T> list) {
        return new PageVo<T>(total, list);
    }

    public static <T> PageVo<T> of(IPage<T> page) {
        return of(page.getTotal(), page.getRecords());
    }
}
